{% extends "main/base.html" %}
{% load i18n static main_tag %}
{% block title %}{% trans '客户' %}{% endblock %}
{% block this_css %}
<link rel="stylesheet" type="text/css" href="{% static 'flatlab/css/bootstrap-select.min.css' %}">
{% endblock %}
{% block content %}
<section class="panel">
    <div class="panel-body">
        <div class="col-md-9">
            <form class="form-inline" role="form" method="get">
                <div class="form-group">
                    <div class="input-group">
                        <input class="form-control" type="text" name="q" placeholder="" value="{% if request.GET.q %}{{ request.GET.q }}{% endif %}">
                        <span class="input-group-btn"><button class="btn btn-primary" type="submit">搜索</button></span>
                    </div>
                </div>
            </form>
        </div>
        <div class="col-md-3" align="right">
            {% if perms.main.add_client %}
            <a href="{% url 'main:client_create' %}?next={{ request.path }}"><button type="button" class="btn btn-success">{% trans "添加客户" %}</button></a>
            {% endif %}
        </div>
    </div>
</section>
<section class="panel">
    {% get_current_language as LANGUAGE_CODE %}
    <div class="table-responsive panel-body">
        <table class="table table-striped">
            <thead>
                <tr>
                    <th>{% trans '姓名' %}</th>
                    <th>{% trans '手机' %}</th>
                    <th>{% trans '微信' %}</th>
                    <th>{% trans '邮箱' %}</th>
                    <th>{% trans '公司' %}</th>
                    <th>{% trans '订单数' %}</th>
                    <th>{% trans '最后更新' %}</th>
                </tr>
            </thead>
            <tbody>{% for d in page_obj %}
                <tr>
                    <td>{% if perms.main.change_client %}<a href="{% url 'main:client_detail' d.id %}">{{ d.name }}</a>{% else %}{{ d.name }}{% endif %}</td>
                    <td>{{ d.mobile|mobile }}</td>
                    {% if perms.main.change_client %}<td>{{ d.wechat }}</td>
                    <td>{{ d.email }}</td>
                    <td>{{ d.company }}</td>{% else %}<td>N/A</td>
                    <td>N/A</td>
                    <td>N/A</td>{% endif %}
                    <td>{{ d.order_count }}</td>
                    <td>{{ d.datetime_updated }}</td>
                </tr>{% endfor %}
            </tbody>
        </table>
        <div align="right">
            {% include 'main/tablenav.html' %}
        </div>
    </div>
</section>
{% endblock %}
{% block this_js %}
<script type="text/javascript" src="{% static 'flatlab/js/bootstrap-select.min.js' %}"></script>
{% endblock %}